
#include "../common/sparse_matrix.h"
#include "../common/dynamic_arr.h"
#include "../common/dynamic_int_arr.h"
#include "../common/modularity_mat.h"
#include "../common/mem.h"

int main(int argc, char** argv)
{
	const char* adjacency_mat_file;
	const char* group_file;
	sparse_matrix_arr* original_matrix;
	ModularityMatrix* Bg;
	int i,j;

	dynamic_int_arr* indices_arr;

	if (argc != 3)
		nice_exit("Usage: %s <adjacency-mat-file> <group-file>\n\n", argv[0]);

	adjacency_mat_file = argv[1];
	group_file = argv[2];

	original_matrix = sparse_matrix__read_from_file(adjacency_mat_file, -1);

	indices_arr = dynamic_int_arr__create_from_file(group_file);

	Bg = make_modularity_mat(original_matrix, indices_arr->values,
		indices_arr->count);

	printf("%i\n", indices_arr->count);
	for (i = 0; i < indices_arr->count; i++)
	{
		for (j = 0; j < indices_arr->count; j++)
		{
			if (modularity_mat_get_cell(Bg, i, j, 1) != modularity_mat_get_cell(Bg, j, i, 1))
				fatal_error("Modularity matrix is not symmetric!");

			printf("%f ", modularity_mat_get_cell(Bg, i, j, 1));
		}

		printf("\n");
	}

	free_all();

	return 0;
}
